<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="EN" lang="EN" dir="ltr">
<%@page import="java.sql.*"%>
<head profile="http://gmpg.org/xfn/11">
<script type="text/javascript" language="javascript">
function validate(){
	alert("Reached........");
	var cmnt=document.getElementById("cmnt").value;
	if(cmnt==null){
		alert("Please Enter Your Comment Before Posting!!!!!");
	}
}
</script>
<script type="text/javascript" language="javascript">
            var xmlHttp;
            function Ajax(){

	try{	
		xmlHttp=new XMLHttpRequest();// Firefox, Opera 8.0+, Safari
	}
	catch (e){
		try{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); // Internet Explorer
		}
		catch (e){
		    try{
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e){
				alert("No AJAX!?");
				return false;
			}
		}
	}

xmlHttp.onreadystatechange=function(){
	if(xmlHttp.readyState==4){
               //alert(xmlHttp.responseText);
               document.getElementById('ReloadThis').innerHTML=xmlHttp.responseText;
	       setTimeout('Ajax()',10000);
	}
}
var str=document.getElementById("did").value;
//var str1=document.getElementById("userid").value;
//alert(str1);
var url="getcomments.jsp?q="+str;
//alert(url);
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

window.onload=function(){
setTimeout('Ajax()',3000);
}
        </script>
<title>Knowledge Share</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="imagetoolbar" content="no" />
<link rel="stylesheet" href="styles/layoutforprofilepage.css" type="text/css" />
       <script src="scripts/slidemenu.js"></script>
        <style type="text/css">
            
            #menu1 {
                background: #676767;
                height: auto;
                width:0px;  
                float:right;
                overflow:hidden;
            }
           /* #menu2 {
                background: #fff;
                height: 100%;
                width:0px;  
                float:right;
                overflow:hidden;
            }
			*/
           #nav-bar {
                background: #2B2B2B;
                height: 615px;
                width:30px; 
                float:right;
            }
            ul.nav-menu{
                padding:0px;
                margin:0;
            }
            ul.nav-menu li{
                list-style-type:none;
                padding:0px;
                width:10px;
                height:400px;
            }
            ul.nav-menu li a{
	display:block;
	width:100px;
	padding:5px;
	position:relative;
	right:42px;
	top:60px;
	color:#2B2B2B;
	text-decoration:none;
	background-color: #2B2B2B;
            }
            ul.nav-menu li a.btn-2{
                top:160px;
            }
            ul.nav-menu li a:hover{
                background-color:#676767;
                color:#2B2B2B;
            }
            
			.rotate {
                -webkit-transform: rotate(-90deg);  /* Safari */
               -moz-transform: rotate(-90deg);     /* Firefox */
                -ms-transform: rotate(-90deg);      /* IE */
                -o-transform: rotate(-90deg);       /* Opera */
                filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3); /* Internet Explorer */
            }
        </style>
		
		<style type="text/css">
		#menu ul
{
    margin: 0px;
    padding: 0px;
    list-style-type: none;
}

#menu a
{
    display:inline-block;
    width: 230px;
	height:60px;
	padding-left:24px;
	padding-top:8px;
	text-transform:uppercase;
    color: white;
    background-color: #676767;
    text-align: left;
}

#menu a:hover
{
    background-color:#2B2B2B;
}
</style>s
</head>
<body id="top">
<div class="wrapper row1">
  <div id="topnav">
    <ul>
      	   <li style="float:right"><a href="logout.jsp"><strong>Log Out</strong></a></li>
    </ul> 
  </div>
</div>
<!-- ####################################################################################################### -->
<div class="wrapper row2">
  <div id="header" class="clear">
    <div class="fl_left">
      <h1><a href="../../Documents/index.html">Knowledge Share </a></h1>
      <p>an online knowledge based community sharing system</p>
    </div>
  </div>
</div>
<!-- ####################################################################################################### -->
<div class="wrapper row4"></div>
<!-- ####################################################################################################### -->
<div class="wrapper row5">

        <div id="menu1">
		
		<div id="menu">
          <ul>
             <li><a href="startdisc.jsp">Start a Discussion</a></li>
             <li><a href="viewdisclist.jsp">View Discussions</a></li>
             <li><a href="#">Upload Video Tutorials</a></li>
			 <li><a href="#">View Video Tutorials</a></li>
			 <li><a href="#">Upload Study Materials</a></li>
			 <li><a href="#">View Study Materials</a></li>
			 <li><a href="#">Live Sessions</a></li>
			 <li><a href="#">View Assessment report</a></li>
			 <li><a href="">Answer Queries</a></li>
         </ul>
       </div>
		
		</div>
        <div id="nav-bar">
            <ul class="nav-menu">
                <li>
                <a name="nav" href="#" class="btn-1 rotate"><img src="images/sliderimg.jpg" width="100" height="30" /></a></li>
            </ul>
        </div><!--/nav-bar-->
        <script type="text/javascript">
            $(document).ready(function()
            {
                var $menu1 = $('#menu1');
                //var $menu2 = $('#menu2');

                $('.btn-1').toggle(
                function()
                {
                    if ($menu1.width() == 250)
                    {
                        $('#menu1').animate({width: "0"}, 500);
                    }
                    else {
                        //$('#menu2').animate({width:'0px'},500);
                        $('#menu1').delay(500).animate({width:'250px'},500);
                    } 
                },
                function()
                {
                    if ($menu1.width() == 250)
                    {
                        $('#menu1').animate({width: "0"}, 500);
                    }
                    else {
                        //$('#menu2').animate({width:'0px'},500);
                        $('#menu1').delay(500).animate({width:'250px'},500);
                    }
                });

             });
        </script>
  <div id="container" class="clear">
  <%! String id=null,dept=null,disid=null,fn=null,ln=null;
    
    %>
    <%
     id=(String)session.getAttribute("id");
     dept=(String)session.getAttribute("dept");
     disid=request.getParameter("q");
     Class.forName("com.mysql.jdbc.Driver");
	 Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/kbcssdb","root","mysql");
	 PreparedStatement ps=con.prepareStatement("select * from discussion where disid=?");
	 ps.setString(1,disid);
     ResultSet rs=ps.executeQuery();
             while(rs.next()){
            	int disid=rs.getInt(1); 
            	PreparedStatement ps1=con.prepareStatement("select * from userdetails where userid=?");
                ps1.setString(1,id);
                ResultSet rs1=ps1.executeQuery();
                while(rs1.next()){
                    fn=rs1.getString("fname");
                    ln=rs1.getString("lname");
                }
     %>
    <!-- ####################################################################################################### -->
     <h1>Discussion Title:</h1><%=rs.getString("distopic") %>
     <br/>
	 <h2>Description:</h2><p><%=rs.getString("disdesc") %></p>
	 <br/>
	 Posted by:<%=fn %>&nbsp;<%=ln %>&nbsp;&nbsp;Date:&nbsp;<%=rs.getString("disdate") %>&nbsp;&nbsp;Time:&nbsp;<%=rs.getString("distime") %>
	 <%} %>
	 <h2>Previous Comments</h2>
	 <p>
	 
	 <br />
	 
	 <br />
	 <form name="fm1" action="Addcmnt.do" method="post">
	 <input type="hidden" name="disid" id="did" value="<%=disid%>">
	    <textarea name="comments" cols="80" rows="3" id="cmnt"></textarea>
		<br />
		<input type="submit" value="POST" onclick="validate();" style="background-color:#2B2B2B; color:#FFFFFF; border:ridge;" />
	 </form>
	 <div id="ReloadThis"></div> 	   
    <!-- ####################################################################################################### -->
  </div>
</div>
<!-- ####################################################################################################### -->
<div class="wrapper"></div>
<!-- ####################################################################################################### -->
<div class="wrapper">
  <div id="footer" class="clear">
    <!-- ####################################################################################################### -->
   
    <div id="copyright" class="clear">
      <p class="fl_left">Copyright &copy; 2012 - All Rights Reserved</p>
      <p class="fl_right">Team CodeX</p>
    </div>
    <!-- ####################################################################################################### -->
  </div>
</div>
</body>
</html>